<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <include file="Public/meta" />
</head>
<body>
    <div class="info-center">
        <div class="page-header">
            <div class="pull-left">
                <h4>分配权限</h4>      
                <a href="javascript:history.go(-1)">
                    <button class="btn btn-default"><i class="fa fa-level-up"></i>返回</button>
                </a> 
            </div>
        </div>
        <div class="clearfix"></div>
        <div class="table-margin">
            <h3 class="text-center">为{$group_data['title']}分配权限</h3>
            <div id="warp">
                <form action="" method="post">    
                    <foreach name="rule_data" item="app">
                        <input type="hidden" value="{$id}" name="id"/>
                        <div class="app b-group">
                            <p>
                                <strong>{$app.title}</strong>
                                <input type="checkbox" name="rule_ids[]" value="{$app['id']}" <if condition="in_array($app['id'],$group_data['rules'])"> checked="checked"</if> onclick="checkAll(this)">
                            </p>
                            <foreach name="app._data" item="action">
                                <dl class="b-group">
                                    <dt>
                                        <strong>{$action.title}</strong>
                                        <input type="checkbox" name="rule_ids[]" value="{$action['id']}" <if condition="in_array($action['id'],$group_data['rules'])"> checked="checked"</if> onclick="checkAll(this)">
                                    </dt>
                                    <foreach name="action._data" item="method">
                                        <dd>
                                            <span>{$method.title}</span>
                                            <input type="checkbox" name="rule_ids[]" value="{$method['id']}" <if condition="in_array($method['id'],$group_data['rules'])"> checked="checked"</if>
                                        </dd>
                                    </foreach>
                                </dl>
                            </foreach>
                        </div>
                    </foreach>
                    <button class="btn btn-primary" style="margin:20px auto;">提交</button>
                </form>
            </div>
        </div>
    </div> 
    <script type="text/javascript" src="__ADMIN_JS__/common.js"></script>
    <script>
    function checkAll(obj){
        $(obj).parents('.b-group').eq(0).find("input[type='checkbox']").prop('checked', $(obj).prop('checked'));
    }
    </script>
</body>
</html>
